<?php
/**
* 店铺服务
*/
class ElemeStoreSvc extends ElemeCommon
{	
    /** 查询店铺信息
     * @param $shop_id 店铺Id
     * @return mixed
     */
    public function getShop($shopId = '')
    {
        $data = array();
        $data['shopId'] = $shopId;
        return $data;
    }
    /** 发送查询店铺信息
     * @param $shop_id 店铺Id
     * @return mixed
     */
    public function sendGetShop($data = array())
    {        
        $action = 'eleme.shop.getShop';
        $postData = $this->getPostData($action, $data);

        $this->DLOG("get_shop : " . json_encode($postData), "run", "channel_eleme");

        $res = $this->doPost($this->api_request_url, $postData);

        $this->DLOG("get_shop_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_eleme");

        return $res;
    }

    /** 更新店铺基本信息
     * @param $shopId 店铺Id
     * @param $shop_name 店铺名称 
     * @param $$promotionInfo 店铺公告信息
     * @param $openTime 店铺营业时间 
     * @param $shipping_fee 配送费
     * @param $isOpen 是否营业
     */
    public function updateShop($shopId = 0, $shop_name = '', $promotionInfo = '', $openTime = '', $shipping_fee = 0, $isOpen = 1)
    {
        $data = array();
        $data['shopId'] = intval($shopId); 

        $data['properties'] = array();
        $data['properties']['name'] = $shop_name; 
        $data['properties']['promotionInfo'] = $promotionInfo;
        $data['properties']['openTime'] = $openTime; 
        $data['properties']['agentFee'] = $shipping_fee; 
        $data['properties']['isOpen'] = $isOpen; 

        return $data;
    }

    /** 
     *  发送更新店铺基本信息
     */
    public function sendUpdateShop($data = array())
    {        
        $action = 'eleme.shop.updateShop';
        $postData = $this->getPostData($action, $data);

        $this->DLOG("update_shop : " . json_encode($postData), "run", "channel_eleme");

        $res = $this->doPost($this->api_request_url, $postData);

        $this->DLOG("update_shop_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_eleme");

        return $res;
    }

    /** 批量获取店铺简要
     * @param $shop_ids 店铺Id的列表
     * @return mixed
     */
    public function mget_shop_status($shop_ids)
    {
        return $this->client->call("eleme.shop.mgetShopStatus", array("shopIds" => $shop_ids));
    }

    /** 设置送达时间
     * @param $shop_id 店铺Id
     * @param $delivery_basic_mins 配送基准时间(单位分钟)
     * @param $delivery_adjust_mins 配送调整时间(单位分钟)
     * @return mixed
     */
    public function set_delivery_time($shop_id, $delivery_basic_mins, $delivery_adjust_mins)
    {
        return $this->client->call("eleme.shop.setDeliveryTime", array("shopId" => $shop_id, "deliveryBasicMins" => $delivery_basic_mins, "deliveryAdjustMins" => $delivery_adjust_mins));
    }

    /** 设置是否支持在线退单
     * @param $shop_id 店铺Id
     * @param $enable 是否支持
     * @return mixed
     */
    public function set_online_refund($shop_id, $enable)
    {
        return $this->client->call("eleme.shop.setOnlineRefund", array("shopId" => $shop_id, "enable" => $enable));
    }
}